package com.example.mydesignmodule.yuanxing;

import java.util.Hashtable;

/**
 * @author tgw
 * @date 2021/2/25
 * @describe 创建一个类，从数据库获取实体类，并把它们存储在一个 Hashtable 中。
 */
public class DocumentCache {

    private static Hashtable<String, Document> shapeMap
            = new Hashtable<String, Document>();

    public static Document getShape(String shapeId) throws CloneNotSupportedException {
        Document cachedShape = shapeMap.get(shapeId);
        return (Document) cachedShape.clone();
//        return cachedShape;
    }

    // 对每种形状都运行数据库查询，并创建该形状
    // shapeMap.put(shapeKey, shape);
    // 例如，我们要添加两种文档形状
    public static void loadCache(WordDocument wordDocument) {
        shapeMap.put(wordDocument.getType(),wordDocument);

        WPsDocument wps = new WPsDocument();
        shapeMap.put(wps.getType(),wps);

    }


}
